﻿expandCollapseDiv = function (divid) {
    var obj = document.getElementById(divid);
    if (obj.style.display == "")
        obj.style.display = "none";
    else
        obj.style.display = "";
}
expandCollapseTree = function (divid, objClick, text1, text2) {
    var obj = document.getElementById(divid);
    if (obj.style.display == "") {
        obj.style.display = "none";
        objClick.innerHTML = text1;
    }
    else {
        obj.style.display = "";
        objClick.innerHTML = text2;
    }
}
expandCollapseSearch = function (divid, idimage, idvalue, img1, img2, istoogle) {
    var obj = document.getElementById(divid);
    var objValue = document.getElementById(idvalue);
    var objImg = document.getElementById(idimage);
    if (istoogle) {
        if (objValue.value == '1') {
            obj.style.display = "none";
            objValue.value = '0';
            objImg.src = getImagePath(objImg.src) + img1;
        }
        else {
            obj.style.display = "";
            objValue.value = '1';
            objImg.src = getImagePath(objImg.src) + img2;
        }
    }
    else {
        if (objValue.value == '0') {
            obj.style.display = "none";
            objImg.src = getImagePath(objImg.src) + img1;
        }
        else {
            obj.style.display = "";
            objImg.src = getImagePath(objImg.src) + img2;
        }
    }
}
getImagePath = function (strpath) {
    var index = 0;
    for (index = strpath.length - 1; index >= 0; index--) {
        if (strpath.charAt(index) == '/') {
            return strpath.toString().substring(0, index + 1);
        }
    }
    return strpath;
}
selectAllCheckboxes = function (spanChk, strid) {
    var theBox = spanChk;
    elm = theBox.form.elements;
    for (i = 0; i < elm.length; i++)
        if ((elm[i].type == "checkbox") && (elm[i].id != theBox.id) && (elm[i].id.indexOf(strid) >= 0)) {
            elm[i].checked = spanChk.checked;
        }
}
getWindowWidth = function () {
    var winW = 630, winH = 460;
    if (document.body && document.body.offsetWidth) {
        winW = document.body.offsetWidth;
    }
    if (document.compatMode == 'CSS1Compat' &&
        document.documentElement &&
        document.documentElement.offsetWidth) {
        winW = document.documentElement.offsetWidth;
    }
    if (window.innerWidth && window.innerWidth) {
        winW = window.innerWidth;
    }
    return winW
}
getWindowHeight = function () {
    var winH = 460;
    if (document.body && document.body.offsetHeight) {
        winH = document.body.offsetHeight;
    }
    if (document.compatMode == 'CSS1Compat' &&
        document.documentElement &&
        document.documentElement.offsetHeight) {
        winH = document.documentElement.offsetHeight;
    }
    if (window.innerHeight) {
        winH = window.innerHeight;
    }
    return winH;
}
var acttachedSizeChanged = Array();
sizeChanged = function (event) {
    var objLeft = document.getElementById("dvLeft");
    var objHead = document.getElementById("dvHead");
    var objFoot = document.getElementById("dvFoot");
    var width = getWindowWidth() - 30;
    if (objLeft) {
        width = width - objLeft.offsetWidth;
    }
    var minHeight = getWindowHeight() - objHead.offsetHeight - objHead.offsetTop - objFoot.offsetHeight - 30;
    if (width >= 400) {
        var objmain = document.getElementById("dvMain");
        objmain.style.width = width + "px";
        objmain.style.minHeight = minHeight + "px";
        if (objLeft) {
            objLeft.style.minHeight = minHeight + "px";
        }
    }
    for (i = 0; i < acttachedSizeChanged.length; i++) {
        acttachedSizeChanged[i](width, minHeight);
    }
}
listenOnSizeChanged = function (fn) {
    acttachedSizeChanged[acttachedSizeChanged.length] = fn;
}
hideScroll = function () {
    if (document.documentElement)
        document.documentElement.style.overflow = 'hidden';  // firefox, chrome
    if (document.body)
        document.body.scroll = "no"; // ie only
}
